<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script th:src="@{/js/button.js}"></script>
</head>
<body>

<div class="row" th:fragment="header">
    <div class="col-md-12">
        <header><h1>微博</h1></header>
    </div>
</div>
<div class="row" th:fragment="topbar">
    <div class="col-md-12">
        <!--导航-->
        <nav class="navbar navbar-default">
            <div class="container-fluid">
                <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                    <ul class="nav navbar-nav">
                        <li th:class="${pageName=='list'?'active':''}">
                            <a th:href="@{/index/list}">首页&nbsp;<span class="glyphicon glyphicon-home"></span></a>
                        </li>
                        <li th:class="${pageName=='attention'?'active':''}"
                            th:if="${not #strings.isEmpty(session.loginUser)}"><a
                                th:href="@{/user/attentionList(pageNo = 1)}">关注的人&nbsp;<span
                                class="glyphicon glyphicon-heart"></span></a>
                        </li>
                        <li th:class="${pageName=='add'?'active':''}"
                            th:if="${not #strings.isEmpty(session.loginUser)}"><a th:href="@{/user/modifyBlog}">写微博&nbsp;<span
                                class="glyphicon glyphicon-pencil"></span></a></li>

                    </ul>
                    <form class="navbar-form navbar-left" method="get" th:action="@{/blog/pageList}"
                          th:if="${pageName}=='list'">
                        <div class="form-group">
                            <input type="text" name="blogKey" th:value="${blogKey} eq ''? '':${blogKey}"
                                   class="form-control" placeholder="标题文字">
                            <select name="blogLabel" class="form-control" style="margin-left: 10px;margin-right: 10px">
                                <option value="0" selected>标签(All)</option>
                                <option th:each="label:${labels}" th:value="${label.id}"
                                        th:text="${label.name}" th:selected="${label.id}==${labeled}"></option>
                            </select>
                            <input type="hidden" name="pageNo" value="1">
                        </div>
                        <button type="submit" class="btn btn-info"><span
                                class="glyphicon glyphicon-search">&nbsp;搜索</span></button>
                    </form>
                    <form class="navbar-form navbar-left" method="get" th:action="@{/user/attentionList}"
                          th:if="${pageName}=='attention'">
                        <div class="form-group">
                            <input type="text" name="bloggerNameKey"
                                   th:value="${bloggerNameKey} eq ''? '':${bloggerNameKey}"
                                   class="form-control" placeholder="标题文字">
                            <input type="hidden" name="pageNo" value="1">
                        </div>
                        <button type="submit" class="btn btn-info"><span
                                class="glyphicon glyphicon-search">&nbsp;搜索</span></button>
                    </form>
                    <form class="navbar-form navbar-left" method="get" th:action="@{/blog/myBlogPageList}"
                          th:if="${pageName}=='myList'">
                        <div class="form-group">
                            <input type="text" name="blogKey" th:value="${blogKey} eq ''? '':${blogKey}"
                                   class="form-control" placeholder="标题文字">
                            <select name="blogLabel" class="form-control"
                                    style="margin-left: 10px;margin-right: 10px">
                                <option value="0" selected>类型(All)</option>
                                <option th:each="label:${labels}" th:value="${label.id}"
                                        th:text="${label.name}" th:selected="${label.id}==${labeled}"></option>
                            </select>
                            <input type="hidden" name="pageNo" value="1">
                            <input type="hidden" name="userId" th:value="${session.userVO.user.id}">

                        </div>
                        <button type="submit" class="btn btn-info"><span
                                class="glyphicon glyphicon-search">&nbsp;搜索</span></button>
                    </form>
                    <ul class="nav navbar-nav navbar-right">
                        <li class="dropdown" th:if="${not #strings.isEmpty(session.loginUser)}">
                            <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button"
                               aria-haspopup="true" aria-expanded="false">我的空间<span class="caret"></span></a>
                            <ul class="dropdown-menu">
                                <li>
                                    <a th:href="@{/blog/myBlogPageList(blogKey='',blogLabel=0,pageNo=1,userId=${session.userVO.user.id})}">我的微博</a>
                                </li>
                                <li><a th:href="@{/user/myCollectList(pageNo = 1)}">我的收藏夹</a></li>
                                <li><a th:href="@{/user/userinfo}">我的信息</a></li>
                                <li><a th:href="@{/user/toModifyPassword}">修改密码</a></li>
                            </ul>
                        </li>
                        <li>
                            <button th:if="${not #strings.isEmpty(session.loginUser)}" id="btn-logout"
                                    type="button"
                                    class="btn btn-default navbar-btn btn-danger">注销
                            </button>
                            <button th:if="${#strings.isEmpty(session.loginUser)}" id="btn-tologin"
                                    type="button"
                                    class="btn btn-default navbar-btn btn-primary">登录
                            </button>
                        </li>
                    </ul>
                </div><!-- /.navbar-collapse -->
            </div><!-- /.container-fluid -->
        </nav>
        <!--END导航-->
    </div>
</div>
<div th:fragment="headerimage">
    <div class="user-box" th:if="${not #strings.isEmpty(session.loginUser)}">
        <div class="user-innerbox">
            <div class="row">
                <div class="col-md-5 col-sm-4 picinfo">
                    <p><a>点赞: <span class="badge" th:text="${session.userVO.likeNumber}"></span></a></p>
                    <p><a>粉丝: <span class="badge" th:text="${session.userVO.fansNumber}"></span></a></p>
                    <p>
                        <a th:href="@{/blog/myBlogPageList(blogKey='',blogLabel=0,pageNo=1,userId=${session.userVO.user.id})}">
                            博客: <span class="badge" th:text="${session.userVO.blogsNumber}"></span></a></p>
                </div>
                <div class="col-md-5 col-sm-5">
                    <a><img th:src="@{/{src}(src=(${session.userVO.user.userImage}==''?'imgs/default.jpg':'upload/'+${session.userVO.user.userImage}))}"
                            class="profile-photo img-circle" alt="Responsive image" id="bloggerImage"/></a>
                </div>
            </div>
        </div>
    </div>
</div>
<div th:fragment="hotrange">

    <!--排行榜-->
    <div class="list-group">
        <a href="#" class="list-group-item" style="background:#ccc" disabled>
            <img th:src="@{/imgs/hot.jpg}" style="width: 20px">&nbsp;热度微博
            <span style="float: right">点赞数</span>
        </a>
        <a th:each="like:${likeRange}" th:href="@{/blog/detail/{id}(id = ${like.id})}" class="list-group-item">
            <span class="badge">[[${like.likes}]]</span>
            <span class="glyphicon glyphicon-fire" style="color: red"></span>&nbsp;[[${like.title}]]
        </a>
    </div>
    <!--END 排行榜-->
    <!--排行榜-->
    <table class="table table-hover" style="margin-top: 10px">
        <caption><img th:src="@{/imgs/range.jpg}" style="width: 20px">&nbsp;阅读排名
            <span style="float: right;margin-right: 5px">浏览量</span></caption>
        <tbody>
        <tr th:each="view,stat:${viewRange}">
            <td th:text="${stat.count}"></td>
            <td><a th:href="@{/blog/detail/{id}(id = ${view.id})}">[[${view.title}]]</a></td>
            <td th:text="${view.views}"></td>
        </tr>
        </tbody>
    </table>
    <!--END 排行榜-->
</div>

<div class="row" th:fragment="footer">
    <div class="col-md-12">
        <!--面板-->
        <div class="panel panel-default" style="margin-top:10px">
            <div class="panel-body text-center">
                Share every little bit of life<br/>
            </div>
        </div>
        <input type="hidden" id="referer" name="referer" th:value="${#request.getHeader('Referer')}">
        <input type="hidden" id="path" name="path" th:value="${#httpServletRequest.getContextPath()}">
        <!--END 面板-->
    </div>
</div>

</body>
</html>